# program equivalent to server.py using XMLRPC

from twisted.internet import reactor, defer
from mediadart.utils import default_start_mqueue
from mediadart.mqueue.mqserver import startMQ, MQServer


class Pippo(Exception):
    pass


class Calculator(MQServer):
    def mq_prod(self, a, b):
        def cb1(result):
            print 'cb1', type(result)
            raise Exception('mamma mia')

        def cb2(result):
            print 'cb2', type(result)
            return result

        d = defer.Deferred()
        reactor.callLater(2, d.callback, 'ok')
        d.addCallbacks(cb1, cb2)
        return d

if __name__=='__main__':
    default_start_mqueue(Calculator)
    reactor.run()

